<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title> - 基本表单</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <link rel="shortcut icon" href="../favicon.ico">
    <link href="/Public/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="/Public/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="/Public/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="/Public/css/animate.css" rel="stylesheet">
    <link href="/Public/css/style.css?v=4.1.0" rel="stylesheet">

</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>客服管理-
                        <small>新建客服账号</small>
                    </h5>
                </div>
                <div class="ibox-content">
                    <form method="post" class="form-horizontal" onsubmit="return false">

                        <div class="form-group">
                            <label class="col-sm-2 control-label">*选择角色</label>
                            <div class="col-sm-10">
                                <select name="rid" id="rid">
                                    <volist name="role" id="vo">
                                        <option value="<{$vo.id}>"><{$vo.name}></option>
                                    </volist>
                                </select>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">*选择公司</label>
                            <div class="col-sm-10">
                                <select name="rid" id="rid_company">
                                    <option value="0">本部</option>
                                    <volist name="company" id="vo">
                                        <option value="<{$vo.id}>"><{$vo.name}></option>
                                    </volist>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">*姓名</label>
                            <div class="col-sm-10">
                                <input class="form-control" type="text" id="name" name="name" placeholder="请输入客服姓名">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">*电话</label>
                            <div class="col-sm-10">
                                <input  class="form-control" type="tel" id="phone" name="phone" placeholder="请输入客服电话">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">*密码</label>
                            <div class="col-sm-10">
                                <input class="form-control" type="password" id="pwd"  name="pwd" placeholder="请输入设置密码">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">*确认密码</label>
                            <div class="col-sm-10">
                                <input class="form-control" type="password" id="repwd"  name="repwd" placeholder="请再次输入密码">
                            </div>
                        </div>

                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-2">
                                <button class="btn btn-primary" type="button" onclick="add()">添加账号</button>
                                <button class="btn btn-white" type="reset">重置</button>
                            </div>
                        </div>
                    </form>

                </div>
            </div>
        </div>
    </div>
</div>

<script src="/Public/js/jquery.min.js?v=2.1.4"></script>
<script src="/Public/js/bootstrap.min.js?v=3.3.6"></script>
<script src="/Public/js/content.js?v=1.0.0"></script>
<script src="/Public/js/plugins/layer/layer.min.js"></script>
<script>
    function add() {
        var index = layer.load(1, {
            shade: [0.1, '#fff'] //0.1透明度的白色背景
        });
        var url = "<{$SRVER_NAME}>/admin.php/CustomerService/Addkefu";
        var tourl = "<{$SRVER_NAME}>/admin.php/CustomerService/kefuList";
        var name = $("#name").val();
        var pwd = $("#pwd").val();
        var phone = $("#phone").val();
        var repwd = $("#repwd").val();
        var rid=$("#rid").val();
        var kf_company=$("#rid_company").val();

        var partten = /^(1(3[0-9]|4[57]|5[0-35-9]|7[0135678]|8[0-9]))\d{8}$/;
        if (name == "" || pwd == "" || phone == "" || repwd == "") {
            layer.close(index);
            layer.alert("请信息填写完整！\r\n", {
                title: '提示框',
                icon: 0,
            });
            return false;
        }
        if (pwd != repwd) {
            layer.close(index);
            layer.alert("两次密码不一样！\r\n", {
                title: '提示框',
                icon: 0,
            });
            return false;
        } else if (pwd.length < 6) {
            layer.close(index);
            layer.alert("密码必须大于六位字符！\r\n", {
                title: '提示框',
                icon: 0,
            });
            return false;
        } else {
            $.post(url, {name: name, phone: phone, pwd: pwd,rid:rid,company:kf_company}, function (data) {
                if (data.code == "1001") {

                    layer.alert('添加成功', {title: '提示框', icon: 1}, function () {
                        window.location.href = tourl;
                        layer.close(index);
                    });
                }
                else {
                    layer.alert(data.result, {title: '提示框', icon: 1});
                    layer.close(index);
                }
            });
        }
    }


</script>
</body>
</html>
